//% color="#17959d" iconWidth=50 iconHeight=40
namespace ASR {
    //% block="initialize ASR RX(blue)[txPin] TX(green)[rxPin]" blockType="command"
    //% txPin.shadow="dropdown" txPin.options="TxPin" 
    //% rxPin.shadow="dropdown" rxPin.options="RxPin" 
    export function set(parameter: any, block: any) {
        let txpin=parameter.txPin.code;
        let rxpin=parameter.rxPin.code; 
        Generator.addImport("from mpython import *");
        Generator.addImport("from asr import *");
        Generator.addDeclaration("GTSerialSetup",`asr = ASR(Pin.${txpin}, Pin.${rxpin})`);
    }

    //% block="Is there ASR data to read?" blockType="boolean"
    export function detected(parameter: any, block: any) {
        Generator.addCode(`asr.detected()`)
    }




    //% block="Is LedControl [LedControl]" blockType="boolean"
    //% LedControl.shadow="dropdown" LedControl.options="LedControl" 
    export function LedControl(parameter: any, block: any) {
        let ledcontrol=parameter.LedControl.code;
        Generator.addCode(`asr.cmdParse() == "${ledcontrol}"`)
    }



    //% block="Is Action [Action]" blockType="boolean"
    //% Action.shadow="dropdown" Action.options="Action" 
    export function Action(parameter: any, block: any) {
        let action = parameter.Action.code;
        Generator.addCode(`asr.cmdParse() == "${action}"`)
    }




    //% block="Is CustomCommand [CustomCommand]" blockType="boolean"
    //% CustomCommand.shadow="dropdown" CustomCommand.options="CustomCommand" 
    export function CustomCommand(parameter: any, block: any) {
        let CustomCommand = parameter.CustomCommand.code;
        Generator.addCode(`asr.cmdParse() == "${CustomCommand}"`)
    }


    //% block="Audio play[TTSWords]" blockType="command"
    //% TTSWords.shadow="dropdown" TTSWords.options="TTSWords" 
    export function tts(parameter: any, block: any) {
        let ttswords = parameter.TTSWords.code; 
        Generator.addCode(`asr.tts_words(${ttswords})`)
    }

    //% block="Audio play[TTSWords]" blockType="command"
    //% TTSWords.shadow="range" TTSWords.params.min=1 TTSWords.params.max=33    TTSWords.defl=1
    export function tts2(parameter: any, block: any) {
        let ttswords = parameter.TTSWords.code; 
        Generator.addCode(`asr.tts_words(${ttswords})`)
    }



    //% block="Audio play[hour]:[minute]" blockType="command"
    //% hour.shadow="number" hour.defl=20
    //% minute.shadow="number" minute.defl=30
    export function tts_clock(parameter: any, block: any) {
        let hour = parameter.hour.code; 
        let minute = parameter.minute.code; 		
        Generator.addCode(`asr.tts_clock(${hour},${minute})`)
    }
	
	

    //% block="Audio play[year]-[month]-[day]" blockType="command"
    //% year.shadow="number" year.defl=2022
    //% month.shadow="number" month.defl=2
    //% day.shadow="number" day.defl=1	
    export function tts_date(parameter: any, block: any) {
        let year = parameter.year.code; 
        let month = parameter.month.code; 
        let day = parameter.day.code; 		
        Generator.addCode(`asr.tts_date(${year},${month},${day})`)
    }


    //% block="Audio play[tts_int]" blockType="command"
    //% tts_int.shadow="number" tts_int.defl=25
    export function tts_int(parameter: any, block: any) {
        let tts_int = parameter.tts_int.code; 
        Generator.addCode(`asr.tts_int(${tts_int})`)
    }
	
	
	//% block="Audio play[tts_double]" blockType="command"
    //% tts_double.shadow="number" tts_double.defl=36.2
    export function tts_double(parameter: any, block: any) {
        let tts_double = parameter.tts_double.code; 
        Generator.addCode(`asr.tts_double(${tts_double})`)
    }


	//% block="Audio play temperature[tts_double]" blockType="command"
    //% tts_double.shadow="number" tts_double.defl=23.5
    export function tts_temp(parameter: any, block: any) {
        let tts_double = parameter.tts_double.code; 
        Generator.addCode(`asr.tts_temp(${tts_double})`)
    }


	//% block="Audio play humidity[tts_double]" blockType="command"
    //% tts_double.shadow="number" tts_double.defl=65.5
    export function tts_humi(parameter: any, block: any) {
        let tts_double = parameter.tts_double.code; 
        Generator.addCode(`asr.tts_humi(${tts_double})`)
    }

}
